﻿using System;
using System.Collections.Generic;
using ZyGames.DZPocker.Model;
using ZyGames.Framework.Cache.Generic;
using ZyGames.Framework.Game.Cache;
using ZyGames.Framework.Game.Context;
using ZyGames.Framework.Game.Contract;
using ZyGames.Framework.Game.Contract.Action;
using ZyGames.Framework.Game.Lang;
using ZyGames.Framework.Game.Service;
using System.Linq;
using ZyGames.DZPocker.Bll.Logic;
using ZyGames.DZPocker.Script;

namespace ZyGames.DZPocker.Script.CsScript.Action
{
	/// <summary>
	/// 广播开始游戏协议 广播开局，庄家、小盲大盲、枪口下盲注
	/// </summary>
	public class Action30003 : BaseAction
	{
		private int bankerId;
		private int bankerPosId;
		private int smallBindPosId;
		private int bigBindPosId;
		/// <summary>
		/// 强制抓头ID
		/// </summary>
		private int gripperPosId;
		private int tableId;

		private int _smallBindBet;
		private int _bigBindBet;
		private int _gripperBet;

		private int _smallBindLeftChip;
		private int _bigBindLeftChip;
		private int _gripperLeftChip;
		public Action30003(HttpGet actionGetter)
			: base((short)ActionType.DZBrocastStartGame, actionGetter)
		{
		}
		public override bool GetUrlElement()
		{
			if (httpGet.GetInt("TableId", ref tableId) &&
				httpGet.GetInt("BankerId", ref bankerId) &&
				httpGet.GetInt("BankerPosId", ref bankerPosId) &&
				//位置
				httpGet.GetInt("SmallBindPosId", ref smallBindPosId) &&
				//累计下的注码
				httpGet.GetInt("SmallBindBet", ref _smallBindBet) &&
				//剩余的筹码
				httpGet.GetInt("SmallBindLeftChip",ref _smallBindLeftChip) &&
				httpGet.GetInt("BigBindPosId", ref bigBindPosId) &&
				httpGet.GetInt("BigBindBet", ref _bigBindBet) &&
				httpGet.GetInt("BigBindLeftChip",ref _bigBindLeftChip) &&

				httpGet.GetInt("GripperPosId", ref gripperPosId) &&
				httpGet.GetInt("GripperBet", ref _gripperBet) &&
				httpGet.GetInt("GripperLeftChip",ref _gripperLeftChip))
			{
				return true;
			}
			return false;
		}

		public override bool TakeAction()
		{
			return true;
		}

		public override void BuildPacket()
		{
			this.PushIntoStack(tableId);
			this.PushIntoStack(bankerId);
			this.PushIntoStack(bankerPosId);
			this.PushIntoStack(smallBindPosId);
			this.PushIntoStack(_smallBindBet);
			this.PushIntoStack(_smallBindLeftChip);
			this.PushIntoStack(bigBindPosId);
			this.PushIntoStack(_bigBindBet);
			this.PushIntoStack(_bigBindLeftChip);
			this.PushIntoStack(gripperPosId);
			this.PushIntoStack(_gripperBet);
			this.PushIntoStack(_gripperLeftChip);
		}
	}
}
